home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group99a.txt / 000168_icon-group-sender _Thu Jul 29 12:28:22 1999.msg < prev    next >
Internet Message Format  |  2000-09-20  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id MAA02945
  4.     for icon-group-addresses; Thu, 29 Jul 1999 12:26:12 -0700 (MST)
  5. Message-Id: <199907291926.MAA02945@baskerville.CS.Arizona.EDU>
  6. From: "Frank Lhota" <lhotaf@lexma.meitech.com>
  7. To: <icon-group@optima.CS.Arizona.EDU>
  8. Subject: How to Bring Back the Old basename
  9. Date: Thu, 29 Jul 1999 12:10:19 -0400
  10. X-Priority: 3
  11. X-MSMail-Priority: Normal
  12. X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
  13. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  14. Status: RO
  15.  
  16. Nevin Liber has a good point regarding basename. Even if the latest version
  17. is closer to the original intentions, as well as the closer to what the name
  18. suggests, there may be many applications dependant on the old behavior. To
  19. keep these applications from breaking, we need to retain the old, quirky
  20. behavior. This is unfortunate for new developers who would rather have
  21. something closer to the Unix utility.
  22.  
  23. Has anyone else noticed how superfluous the second parameter to the old
  24. basename is? The old basename chops off the extension whether or not the
  25. second parameter is specified, and whether or not it is present, so when
  26. does specifying an extension make a difference?
  27.  
  28. The best option for now may be to fix basename to return the old behavior,
  29. and also update the documentation to clarify the quirk. Here is my proposal:
  30.  
  31. ############################################################################
  32. #
  33. # File:     basename.icn
  34. #
  35. # Subject:  Procedures to produce base name of a file
  36. #
  37. # Author:   Ralph E. Griswold
  38. #
  39. # Date:     September 22, 1998
  40. #
  41. ############################################################################
  42. #
  43. #   This file is in the public domain.
  44. #
  45. ############################################################################
  46. #
  47. #  Contributor:  Charles Shartsis
  48. #
  49. ############################################################################
  50. #
  51. #  This procedure is based on the UNIX basename(1) utility.  It strips off
  52. #  any path information and removes the specified suffix, if present.
  53. #
  54. #  If no suffix is provided, or if the suffix is not at the end of the name,
  55. #  the portion of the name up to the first "." is returned.
  56. #
  57. #  It should work under UNIX, MS-DOS, and the Macintosh.
  58. #
  59. ############################################################################
  60.  
  61. procedure basename(name, suffix) #: base name of file
  62.    local base
  63.  
  64.    name ? {
  65.       while tab ( upto('/\\:') + 1 )  # get rid of path, if any
  66.       if ( base := tab ( -*\suffix ) ) & =suffix
  67.          then return base
  68.          else return tab ( find ( "." ) | 0 )
  69.       }
  70.  
  71. end
  72.  
  73.  
  74.  
  75.